package com.view;

import java.awt.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.*;  

public class Fat extends JFrame{
	JTable table,table1,table2;  
    public Fat()  
    {  
    	this.setTitle("文件分配表FAT");
		this.setSize(800, 400);
		this.setLocation(325, 200);
		int a[]=new int[128];//定义数组a[128]
		
		FileReader fr=null;
		try {
			fr = new FileReader("resources/test2.txt");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        BufferedReader br=new BufferedReader(fr);
        String line="";
        int i=0;
        try {
			while ((line=br.readLine())!=null) {
				int d = Integer.parseInt(line);
				a[i]=d;a[0]=-1;
				i++;
//            System.out.println(d);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        try {
			br.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        try {
			fr.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
        setLayout(new GridLayout(0,16));           //设置为网格布局，未指定行数

        setFont(new Font("Helvetica", Font.PLAIN, 7));
for(int k=0;k<128;k++){
        getContentPane().add(new JButton("<html>"+k+"<br>"+a[k]+"</html>"));
}
     
 
        setVisible(true);  
 
    }  

}
